package com.macro.mall.service.impl;

import cn.dev33.satoken.session.SaSession;
import cn.dev33.satoken.stp.StpUtil;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.common.constant.AuthConstant;
import com.macro.mall.mapper.UmsMemberReceiveAddressMapper;
import com.macro.mall.model.UmsMember;
import com.macro.mall.model.UmsMemberReceiveAddress;
import com.macro.mall.service.UmsMemberReceiveAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UmsMemberReceiveAddressServiceImpl implements UmsMemberReceiveAddressService {
    @Autowired
    private UmsMemberReceiveAddressMapper mapper;
    /**
     * 收货地址
     */
    @Override
    public List<UmsMemberReceiveAddress> list() {
        UmsMember userDto = (UmsMember) StpUtil.getSession().get(AuthConstant.STP_MEMBER_INFO);

        List<UmsMemberReceiveAddress> list = mapper.list(11);

        return list;
    }
    /**
     * 添加和修改
     */
    @Override
    public CommonResult addMember(UmsMemberReceiveAddress umsMemberReceiveAddress) {
           //添加
        Long id = Long.valueOf(11);
        umsMemberReceiveAddress.setMemberId(id);
         mapper.insert(umsMemberReceiveAddress);

       return CommonResult.success(umsMemberReceiveAddress);
    }
    @Override
    public CommonResult update(UmsMemberReceiveAddress umsMemberReceiveAddress) {
         mapper.updateByPrimaryKeySelective(umsMemberReceiveAddress);
         return CommonResult.success(umsMemberReceiveAddress);
    }
    /**
     * 回显
     */
    @Override
    public UmsMemberReceiveAddress byid(Long id) {
        UmsMemberReceiveAddress byid = mapper.selectByPrimaryKey(id);
        return byid;
    }
    /**
     * 删除
     */
    @Override
    public int del(Long id) {
         return  mapper.deleteByPrimaryKey(id);

    }


}
